/******************************************************************************
 * SVN­Version­Information:
 * ­­­­­­­­­­­­­­­­­­­­­­­­---------------------
 * $LastChangedRevision: 6 $
 * $LastChangedBy: c.a.duevel $
 * $LastChangedDate: 2009-08-26 15:12:37 +0000 (Wed, 26 Aug 2009) $
 * $HeadURL: http://robofight.googlecode.com/svn/trunk/Server/src/de/hft_stuttgart/botwar/server/model/AggressiveMode.java $
 ******************************************************************************/
package de.hft_stuttgart.botwar.server.model;

import de.hft_stuttgart.botwar.common.models.Position;
import java.util.Collection;

/**
 *
 * @author sdegiorgi@gmail.com, c.a.duevel@gmail.com
 */
class AggressiveMode extends RobotMode {


    /**
     * @param thisRobot
     * @param robots
     * @return always fires at the nearest Robot
     */
    Robot fireAt(final Robot thisRobot, final Collection<Robot> robots) {
        Robot nearestVictim = findNearestVictim(thisRobot, robots);
        if (thisRobot.isInRange(nearestVictim)) {
            return nearestVictim;
        } else {
            return null;
        }
    }
    /**
     *
     * @param thisRobot
     * @param robots
     * @return
     */

    Position getTarget(final Robot thisRobot, final Collection<Robot> robots) {
        if(thisRobot.getPos().equals(thisRobot.getUserTarget())){
            thisRobot.deleteUserTarget();
        }
        if(thisRobot.getUserTarget() != null){
            return thisRobot.getUserTarget();
        }
        Robot nearestVictim = findNearestVictim(thisRobot, robots);
        if (thisRobot.isInRange(nearestVictim)) {
            return null;
        } else {
            return nearestVictim.getPos();
        }
    }
}

